
<template>
  <div>
    <template>
      <el-table
        :data="tableData"
        header-row-class-name="table-list-header"
        highlight-current-row
        border
        style="width: 100%"
      >
        <el-table-column prop="evaluateTime" label="评价时间" width="180" />
        <el-table-column prop="goodsName" label="商品名称" min-width="200" />
        <el-table-column prop="evaluateContent" label="评价内容" min-width="200" />

        <el-table-column prop="" width="90" label="商家回复">
          <template slot-scope="scope"><el-button type="text" size="mini" @click="toDetail( scope.row.storeReplys)">详情</el-button></template>
        </el-table-column>
        <el-table-column prop="" width="90" label="评价结果">
          <template slot-scope="scope">{{ formaterData(evaluateResultList,scope.row.evaluateResult) }}</template>
        </el-table-column>
        <el-table-column prop="logisticsScore" label="物流评分" width="90" />
        <el-table-column prop="serviceScore" label="服务评分" width="90" />
        <el-table-column prop="customerReviews" label="顾客追评" width="180" />
        <el-table-column prop="storeReviewsReply" label="商家追评回复" width="180" />
        <el-table-column prop="" width="120" label="评价角色(淘系)">
          <template slot-scope="scope">{{ formaterData(roleList,scope.row.evaluationRole) }}</template>
        </el-table-column>
        <el-table-column prop="" width="120" label="是否计分(淘系)">
          <template slot-scope="scope">{{ scope.row.validScore===1?'是':'否' }}</template>
        </el-table-column>
      </el-table>
      <el-dialog
        title="商家恢复详情"
        :visible.sync="dialogVisible"
        width="70%"
        center
        :before-close="handleClose"
      >
        <el-table
          height="250"
          :data="detailData"
          header-row-class-name="table-list-header"
          highlight-current-row
          border
          style="width: 100%"
        >
          <el-table-column prop="replyTime" label="回复时间" width="200" />
          <el-table-column prop="replyContent" label="回复内容" />
        </el-table>
      </el-dialog>
    </template>
  </div>
</template>

<script>
import tabMixin from './mixin'
import { getOrderEvaluate } from '@/api/mscInfo'
import { getDictByPatchType } from '@/api/dataDict'

export default {
  name: 'OrderEvalutionList',
  mixins: [tabMixin],
  data() {
    return {
      tableData: [],
      detailData: [],
      roleList: [], // 评价角色列表
      evaluateResultList: [], // 评价结果列表
      dialogVisible: false,
      otherFilters: [], // 表格额外查询条件
      otherRaws: {}
    }
  },
  computed: {

  },
  async  created() {
    const { EVALUATE_RESULT, EVALUATE_ROLE } =
     await getDictByPatchType('eco', ['EVALUATE_RESULT', 'EVALUATE_ROLE'])
    this.roleList = EVALUATE_ROLE
    this.evaluateResultList = EVALUATE_RESULT
  },
  methods: {
    toDetail(storeReplys) {
      if (!storeReplys || storeReplys.length === 0) {
        this.$message('暂无详情信息')
        return
      }
      this.detailData = storeReplys
      this.dialogVisible = true
    },
    handleClose(done) {
      done()
      setTimeout(() => {
        this.detailData = []
      }, 1000)
    },
    // 数据字典格式化数据
    formaterData(arr, data) {
      if (!data || !arr) {
        return data || ''
      }
      var value = data
      arr.forEach(el => {
        if (el.dictCode === data) value = el.dictName
      })
      return value
    },
    initData() {
      getOrderEvaluate(this.orderData.dcCode || '', this.orderData.platformCode || '').then(res => {
        if (res.success === 1) {
          this.tableData = res.data
        }
      })
    }
  }
}

</script>
<style lang='scss' scoped>
</style>
